/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"E80891C6-FFE8-4CD8-81F0-32932A538007",variableType:4}
 */
var fes_alta = null;

/**
 * @type {Date}
 *
 * @properties={typeid:35,uuid:"024E6679-73E1-4CB8-A40D-16A164DEC599",variableType:93}
 */
var ffecha = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"B866D08B-97AA-4DE1-8D38-0DC1A1676146",variableType:8}
 */
var fvalor = null;

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"C1555F7D-0F35-4253-B81E-BD368C13B6D3"}
 */
function onShow(firstShow, event) {
	ffecha = null
	fvalor = 0
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"DD8F8526-B7F7-44FD-9C40-3900276A05DD"}
 */
function onAction_guardar(event) {
	if (ffecha == 0 & ffecha == null){
		globals.DIALOGS.showWarningDialog("Aviso","Debe ingresar una fecha","Ok")
	}
	databaseManager.setAutoSave(false)
	if (fes_alta == 0) {
		controller.newRecord()
	}
	fecha = ffecha
	valor = fvalor
	moneda = 2
	var estado = databaseManager.saveData()
	if (estado == false){
		globals.DIALOGS.showWarningDialog("Aviso","No se actualizaron los datos","Ok")
		databaseManager.revertEditedRecords()
		return
	}
	globals.mostrarForm('home')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"86CC7CC3-674A-42BC-9E48-C6488452EEA7"}
 */
function onAction_salir(event) {
	globals.mostrarForm('home')
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"38AE41CC-0073-4A7A-86DB-D50076BEFD61"}
 * @AllowToRunInFind
 */
function onDataChange_fecha(oldValue, newValue, event) {
	var estado = controller.find()
	if (estado == false)
	{
		globals.DIALOGS.showWarningDialog("Aviso","Error al hacer el find","Ok")
		return true
	}
	moneda = 2
	var fdes = utils.dateFormat(ffecha,"dd-MM-yyyy")
	var selec_fecha = "#" + fdes + "..." + fdes + "|dd-MM-yyyy"
	fecha =  selec_fecha 
	fes_alta = controller.search()
	if (fes_alta == 0)
	{
		fvalor = 0
	}
	else 
	{
		fvalor = valor		
	}
	return true
}
